import {ref} from 'vue'
import {FONT_SIZE} from '@/common/storageKeys'

// 字体大小
export const useSize = () => {
  const size = ref(localStorage.getItem(FONT_SIZE) || 'base')
  document.documentElement.classList.remove('large', 'base', 'small')
  document.documentElement.classList.add(size.value)
  const toggleSize = (type) => {
    size.value = type
    document.documentElement.classList.remove('large', 'base', 'small')
    document.documentElement.classList.add(type)
    // 存储当前主题
    localStorage.setItem(FONT_SIZE, type)
  }
  return [size, toggleSize]
}
